<?php

/**
 * alltosun.com 操作日志配置 log_config.php
 * ============================================================================
 * 版权所有 (C) 2009-2012 北京互动阳光科技有限公司，并保留所有权利。
 * 网站地址: http://www.alltosun.com
 * ----------------------------------------------------------------------------
 * 许可声明：这是一个开源程序，未经许可不得将本软件的整体或任何部分用于商业用途及再发布。
 * ============================================================================
 * $Author: 钱有明 (qianym@alltosun.com) $
 * $Date: 2012-10-18 下午7:46:09 $
 * $Id: log_config.php 24687 2013-04-22 04:11:56Z qianym $
 */
class goods_config
{

    const CATEGORY_BULK = 1;

    // 操作类型
    public static $search_list = array(
        '0' => '推荐',
        '5' => '最新',
        '10' => '价格从高到低',
        '15' => '价格从低到高',
    );

    public static $cup_type = array(
        '1' => '小杯',
        '5' => '中杯',
        '10' => '大杯',
        '15' => '小杯/中杯',
        '20' => '中杯/大杯',
        '25' => '小杯/大杯',
        '30' => '小杯/中杯/大杯'
    );

    public static $unit = array(
        //件箱个桶袋杯罐台套组
        '0' => '件',
        '1' => '箱',
        '2' => '个',
        '3' => '桶',
        '4' => '袋',
        '5' => '杯',
        '6' => '罐',
        '7' => '台',
        '8' => '套',
        '9' => '组'
    );

    /**
     * 分类
     * @var
     */
    private static $category;

    /**
     * 分类列表获取, 并缓存
     * @return array
     * @throws AnException
     */
    public static function goods_category() {
        if (!isset(self::$category)) {
            self::$category = array_to_filelds_assoc('id', _model('goods_category')->getList(array('status' => 1), ' ORDER BY `id` ASC'));
        }
        return self::$category;
    }


    /**
     * 商品列表
     * @var
     */
    private static $goods;

    /**
     * 商品列表
     * @return array
     * @throws AnException
     */
    public static function goods_list() {
        if (!isset(self::$goods)) {
            self::$goods = array_to_filelds_assoc('id', _model('goods')->getList(array('status' => 1), ' ORDER BY `id` ASC'));
        }
        return self::$goods;
    }


    private static $goods_category_ids;

    /**
     * 获取全部商品的分类索引
     */
    public static function get_goods_category_ids() {
        if (!isset(self::$goods_category_ids)) {
            $goods_list = self::goods_list();
            $index = array();
            foreach ($goods_list as $item) {
                $index[$item['id']] = $item['category_id'];
            }
            self::$goods_category_ids = $index;
        }

        return self::$goods_category_ids;
    }
}

?>